#生成逻辑图像
import networkx as nx
import matplotlib.pyplot as plt
import matplotlib
matplotlib.rcParams['font.sans-serif'] = ['SimHei'] 
matplotlib.rcParams['font.family']='sans-serif'

f = open("./result/ipv6_school_s2d_change.txt",'r',encoding='utf8')

t = []
line = []
while True:
    school = f.readline().replace('\n','')
    if len(school)==0:
        break
    else:
        school_list = school.split(',')

        if school_list[0] not in t:
            t.append(school_list[0])

        if school_list[1] not in t:
            t.append(school_list[1])
        
        line.append(tuple([school_list[0],school_list[1]]))

f.close()

#建立一个空的无向图G
G = nx.Graph() 
#添加点的集合
G.add_nodes_from(t)
#通过添加list来添加多条边
G.add_edges_from(line)
nx.draw(G, with_labels=True)
plt.show()